<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template v-cloak>
    <div class="outer">
        <div class="empty" v-if="isEmpty">
            <empty>
                <div>请从右侧设置面板中选择添加文章</div>
            </empty>
        </div>
        <style0 :items="items" />
    </div>
</template>
<script>
import Style0 from "./Style0";

import { getNewsList } from "@/api/weapp";
import Empty from "../Base/Empty";
export default {
    components: { Empty, Style0 },
    props: {
        module: { type: Object },
    },

    mounted: function () {
        this.loadData();
    },

    watch: {
        "module.ids": function (ids) {
            if (!ids || ids.length == 0) {
                this.loading = false;
                this.items = [];
                return;
            }
            this.loadData();
        },
    },

    computed: {
        isEmpty: function () {
            if (!this.module.ids) {
                return true;
            }
            if (this.module.ids.length == 0) {
                return true;
            }
            return false;
        },
    },
    data () {
        return {
            items: [],
            loading: false,
        };
    },

    methods: {
        loadData: function () {
            if (!this.module.ids || this.module.ids.length == 0) {
                return;
            }
            this.loading = true;
            var query = { ids: this.module.ids.join(",") };
            getNewsList(query).then((resp) => {
                this.loading = false;
                if (resp.status == 0) {
                    this.items = resp.data
                }
            });
        },
    },
};
</script>

<style scoped>
.outer {
    width: 100%;
}
</style>